#include <QtCore/QCoreApplication>
#include <memory>
#include <tr1/memory>
#include <iostream>
#include "personne.h"
#include "etudiant.h"
using namespace std;


class test
{
public:
   void print() {std::cout << "test::print" << std::endl;}
};


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    tr1::shared_ptr<test> sp1(new test);
    sp1->print();
    std::cout << "sp1 adresse: " << sp1.get() << std::endl;

    tr1::shared_ptr<test> sp2;
    std::cout << "sp2 adresse: " << sp2.get() << std::endl;
    sp2 = sp1;
    sp2->print();
    std::cout << "sp1 adresse: " << sp1.get() << std::endl;
    std::cout << "sp2 adresse: " << sp2.get() << std::endl;

    std::cout << "compteur sp1: " << sp1.use_count() << std::endl;
    std::cout << "compteur sp2: " << sp2.use_count() << std::endl;

    tr1::shared_ptr<Personne> personne(new Etudiant);
    tr1::shared_ptr<Etudiant> etudiant(new Etudiant);
    std::cout << "personne adresse : " << personne.get() << std::endl;
    std::cout << "etudiant adresse : " << etudiant.get() << std::endl;
    personne = etudiant;
    std::cout << "personne adresse : " << personne.get() << std::endl;
    std::cout << "etudiant adresse : " << etudiant.get() << std::endl;

    return a.exec();
}




